from celery import Celery

# 消息中间件
# backend = 'redis://:123456@127.0.0.1:6379/1'
backend = 'redis://127.0.0.1:6379/2'
# 结果存储
broker = 'redis://127.0.0.1:6379/1'

app = Celery('test', broker=broker, backend=backend, include=[
    'celery_task.home_task',
    'celery_task.user_task',
    'celery_task.order_task',
])

# celery的配置信息
# 时区
app.conf.timezone = 'Asia/Shanghai'
# 是否使用UTC
app.conf.enable_utc = False

# 配置定时任务
from datetime import timedelta
from celery.schedules import crontab

app.conf.beat_schedule = {
    'send_sms_5': {
        'task': 'celery_task.user_task.send_sms',  # 指定哪个任务
        'schedule': timedelta(seconds=5),  # 每5s干一次
        # 'schedule': crontab(hour=8, day_of_week=1),  # 每周一早八点
        'args': ('18988377473',),
    },
}
